#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 3e6+3;
int prime[MAXN], p_cnt;
bool not_p[MAXN];
LL phi[MAXN];
LL mu[MAXN];
void Init() {
    phi[1] = 1;
    mu[1] = 1;
    p_cnt = 0;
    for (int i=2; i<MAXN; ++i) {
        if (!not_p[i]) {
            prime[p_cnt++] = i;
            phi[i] = i-1;
            mu[i] = -1;
        }
        for (int j=0; j<p_cnt&&i*prime[j]<MAXN; ++j) {
            not_p[i*prime[j]] = true;
            if (i%prime[j] == 0) {
                phi[i*prime[j]] = phi[i] * prime[j];
                mu[i*prime[j]] = 0;
                break;
            }
            phi[i*prime[j]] = phi[i] * (prime[j] - 1);
            mu[i*prime[j]] = -mu[i];
        }
    }
    for (int i=1; i<MAXN; ++i) {
        mu[i] += mu[i-1];
        phi[i] += phi[i-1];
    }
}
struct node {
    LL phi, mu;
    node(LL a, LL b) {phi=a; mu=b;}
    node() {}
};
map<LL, node> ansMap;
node solve(LL n) {
    if (n<MAXN) return node(phi[n], mu[n]);
    if (ansMap.count(n)) return ansMap[n];
    LL retPhi = n*(n+1)/2;
    LL retMu = 1;
    for (LL i=2,last; i<=n; i=last+1) {
        last = n/(n/i);
        node t = solve(n/i);
        retPhi -= (last-i+1)*t.phi;
        retMu -= (last-i+1)*t.mu;
    }
    ansMap[n] = node(retPhi, retMu);
    return node(retPhi, retMu);
}

int main() {
#ifdef hai
    freopen("in.txt", "r", stdin);
#endif
    Init();
    int T;
    cin>>T;
    LL n;
    while (T--) {
        scanf("%lld", &n);
        node t = solve(n);
        printf("%lld %lld\n", t.phi, t.mu);
    }
    return 0;
}
